    // 模态框弹出
    $('#addModal').on('show.bs.modal', function(e) {
        var $this = $(this);
        var $modal_dialog = $this.find('.modal-dialog');
        $this.css('display', 'block');
        $modal_dialog.css({ 'margin-top': Math.max(0, ($(window).height() - $modal_dialog.height()) / 2 - 30) });

    });
    var addOrSave = true;
    // 触发弹出
    $('#btn_add').on('click', function(e) {
        e.preventDefault();
        addOrSave = true;
        sessionStorage.removeItem('edit_id');
        $('#nickname').val('');
        $('#idCard').val('');
        $("#addModal").modal({ backdrop: true, keyboard: true });
    });
    $('#add_submit').click(function(e) {
        e.preventDefault();
        let data = {};
        let forms = $('.form-add');
        $.each(forms, function(index, input) {
            data[input.name] = input.value;
        });
        window.console.log(data);
        let methodName = addOrSave ? 'add' : 'save';
        if ('save' == methodName) {
            data.id = sessionStorage.getItem('edit_id');
        }
        $.ajax({
            type: "put",
            url: server + "/person/" + methodName,
            data: data,
            dataType: "json",
            success: function(response) {
                switch (response.code) {
                    case '200':
                        // $('#add_cancle').toggle('click');
                        getPersons();
                        $('#addModal').modal('hide');
                        // $('#addModal').css('display', 'none');
                        $(".modal-backdrop.fade").hide();
                        break;
                    case '10086':

                        break;

                    default:
                        break;
                }
            }
        });
    });
    // 删除员工
    $('#btn_del').click(function(e) {
        e.preventDefault();
        let list = new Array();
        $('.form-check').each(function(index, element) {
            if (element.checked) {
                list.push(element.value);
            }
        });
        if (list.length > 0) {
            $.ajax({
                method: "delete",
                url: server + "/person/delete",
                async: false,
                contentType: 'application/json;charset=utf-8;',
                data: JSON.stringify(list),
                dataType: 'json',
                success: function(respose) {
                    switch (respose.code) {
                        case "200":
                            {
                                getPersons();
                                break;
                            }
                    }
                }
            });
        } else {
            layer.msg('请选择要删除的员工', { icon: 2 });
        }
    });
    $('#btn_info').click(function(e) {
        e.preventDefault();
        let list = new Array();
        $('.form-check').each(function(index, element) {
            if (element.checked) {
                list.push(element.value);
            }
        });
        if (list.length > 0) {
            $.ajax({
                method: "get",
                url: server + "/person/info/" + list[0],
                async: false,
                dataType: 'json',
                success: function(respose) {
                    switch (respose.code) {
                        case "200":
                            {
                                $("#infoModal").modal({ backdrop: true, keyboard: true });
                                $('#info_nickname').val(respose.data.name);
                                $('#info_idCard').val(respose.data.idCard);
                                break;
                            }
                    }
                }
            });
        } else {
            layer.msg('请选择要查看的员工', { icon: 2 });
        }
    });
    $('#btn_edit').click(function(e) {
        e.preventDefault();
        addOrSave = false;
        let list = new Array();
        $('.form-check').each(function(index, element) {
            if (element.checked) {
                list.push(element.value);
            }
        });
        if (list.length > 0) {
            $.ajax({
                method: "get",
                url: server + "/person/info/" + list[0],
                async: false,
                dataType: 'json',
                success: function(respose) {
                    switch (respose.code) {
                        case "200":
                            {
                                $("#addModal").modal({ backdrop: true, keyboard: true });
                                $('#nickname').val(respose.data.name);
                                $('#idCard').val(respose.data.idCard);
                                sessionStorage.setItem('edit_id', list[0]);
                                break;
                            }
                    }
                }
            });
        } else {
            layer.msg('请选择要查看的员工', { icon: 2 });
        }
    });

    $('#isAll').change(function(e) {
        if ($('#isAll').is(':checked')) {
            $('.form-check').each(function(index, element) {
                if (!element.checked) {
                    element.checked = true;
                }
            });
        } else {
            $('.form-check').each(function(index, element) {
                if (element.checked) {
                    element.checked = false;
                }
            });
        }
    });

    $('.form-check').click(function(e) {
        e.preventDefault();
    });


    $('tr').slice(1).click(function(e) {
        // let checkbox = $("input[type='checkbox']",this)[0];
        let checkbox = $("input:checkbox", this)[0];
        if (checkbox.checked) {
            checkbox.checked = false;
        } else {
            checkbox.checked = true;
        }
        check($('.form-check'));
    })

    function check(items) {
        let flag = true;
        $(items).each(function(index, element) {
            if (!element.checked) {
                flag = false;
            }
        });
        let isAll = window.document.querySelector(`#isAll`)
        isAll.checked = flag;
    }